package com.wm.blog_web.service;


import com.wm.blog_common.base.BeanUtils;
import com.wm.blog_common.domain.TAdminDO;
import com.wm.blog_common.entity.TAdmin;
import com.wm.blog_common.result.Result;
import com.wm.blog_web.dao.TAdminDAO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 管理员表 服务实现类
 * </p>
 *
 * @author 半卷流年
 * @since 2020-03-24
 */
@Service
@Slf4j
public class TAdminService {
    @Autowired
    private TAdminDAO tAdminDAO;

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    public Result<TAdminDO> selectById(Long id){
        return Result.success(BeanUtils.copyProperties(tAdminDAO.getById(id), TAdminDO.class));
    }

    /**
    * 根据ID删除
    * @param id
    * @return
    */
    public Result deleteById(Long id){
        return tAdminDAO.removeById(id)? Result.success(): Result.failure();
    }

    /**
    * 添加
    * @param tAdmin
    * @return
    */
    public Result insert(TAdmin tAdmin){
        return tAdminDAO.save(tAdmin)? Result.success(): Result.failure();
    }

    /**
    * 修改
    * @param tAdmin
    * @return
    */
    public Result update(TAdmin tAdmin){
        return tAdminDAO.updateById(tAdmin)? Result.success(): Result.failure();
    }


}







